<template>
  <el-dialog
    width = "420px"
    center
    :title = "title"
    :visible.sync = "visible"
    :destroy-on-close = "true"
    @closed = "handCancel"
  >
    <div id="meQrcode" :title="label">
      <vue-qr
        :text="text"
        :size="300"
        :margin="0"
        colorDark="black"
        colorLight="white"
      ></vue-qr>
      <div class="labelBox" v-for="(item, index) in list" :key="index">
        {{ item }}
      </div>
    </div>
    <div slot="footer" class="modal-footer">
      <el-button type="primary" @click="savePoster('meQrcode', title)"
        >下载</el-button
      >
      <el-button @click="handCancel">取消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import VueQr from "vue-qr";
import { savePoster } from "@/unit/tool";
export default {
  props: {
    //二维码底部文字
    label: {
      default: "",
    },
    //logo尺寸（正方形 长宽相同）
    text: {
      default: "",
    },
    //对话框宽度
    qrSize: {
      default: "",
    },
  },
  components: { VueQr },
  data() {
    return {
      title: "",
      visible: false,
      list: [],
    };
  },
  methods: {
    savePoster,
    showModal() {
      this.visible = true;
    },
    handCancel() {
      this.visible = false;
    },
  },
};
</script>
<style lang="scss" scoped>
.qrcode_box,
#meQrcode {
  display: inline-block;
  padding: 10px 10px 0 10px;
}

.qrcode_box img {
  display: none;
}

.modal-footer {
  text-align: center;
  margin: 20px 0 0 0;
  button {
    margin: 0 20px;
  }
}
::v-deep .el-dialog__body {
  text-align: center;
}
::v-deep .ant-modal-body {
  text-align: center !important;
}
.labelBox {
  text-align: center;
  font-size: 20px;
  margin: 5px 0;
}
</style>
